*Author: Jason Premo
*Date: 1/24/17

*** Purpose: To fill out the table in the paper with the Oct 2012
** TTMS numbers.

clear all
set more off

local in_path /shared/sdsjxs/Townsend/rawdata/ttms
local out_path /shared/sdsjxs/Townsend/results

use "`in_path'/ttms_month_170.dta", clear

*Keep variable labels (for easier use later)
preserve
drop check* id month
describe, replace clear
keep name varlab
tempfile labels
save `labels', replace
restore

*Do the collapse
collapse (mean) agg_*

xpose, varname clear

rename _varname name
rename v1 mean_baht

*Convert from bahts to dollars.
*Exchange rate (30.68) from haver. Code: FXTHA@USECON
gen mean_usd = mean_baht/30.68
merge 1:1 name using `labels', nogen

order name mean_usd mean_baht

*Output it
export excel using "`out_path'/balance_sheet.xlsx", sheet("ttms_data", replace)
